//
//  MainNavgationController.m
//  AnecdotesDemo
//
//  Created by LYoung on 15/10/13.
//  Copyright (c) 2015年 LYoung. All rights reserved.
//

#import "MainNavgationController.h"

@interface MainNavgationController ()<UIGestureRecognizerDelegate>

@end

@implementation MainNavgationController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
//    UIImage *bgImage = nil;
//    if (iOS7) {
//        bgImage = [AppTools imageWithColor:TheThemeColor];
//    } else {
//        bgImage = [UIImage imageNamed:@"navBackgroundImg"];
//    }
//    bgImage = [bgImage stretchableImageWithLeftCapWidth:0.5 topCapHeight:0.5];
//    [self.navigationBar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
    self.automaticallyAdjustsScrollViewInsets = NO;
    //    UIImage *bgImage = nil;
    //    if (iOS7) {
    //        bgImage = [AppTools imageWithColor:TheThemeColor];
    //    } else {
    //        bgImage = [UIImage imageNamed:@"navBackgroundImg"];
    //    }
    //    bgImage = [bgImage stretchableImageWithLeftCapWidth:0.5 topCapHeight:0.5];
    //    [self.navigationBar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
    
    self.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:KColorWhite forKey:NSForegroundColorAttributeName];
    
    [self.navigationBar setBackgroundImage:[ZQColorChangeImage createImageWithColor:MAIN_Color] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    
    [self.navigationBar setShadowImage:[UIImage new]];
}

#pragma mark 隐藏tabbar
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    [super pushViewController:viewController animated:YES];
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
    
    if (self.navigationController.viewControllers.count == 1){
        return NO;
    }else{
        return YES;
    }
}

@end
